package com.xsd.xsdhouduan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.xsd.xsdhouduan.entity.Admin;
import com.xsd.xsdhouduan.mapper.AdminMapper;
import com.xsd.xsdhouduan.service.AdminService;
import org.springframework.stereotype.Service;

/**
 * 管理员服务实现类
 */
@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper, Admin> implements AdminService {
    
    @Override
    public Admin login(String account, String password) {
        Admin admin = getByAccount(account);
        if (admin != null && password.equals(admin.getPassword())) {
            return admin;
        }
        return null;
    }
    
    @Override
    public Admin getByAccount(String account) {
        LambdaQueryWrapper<Admin> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Admin::getAccount, account);
        return getOne(wrapper);
    }
}
